from enum import Enum


class Charset(Enum):
    GB2312 = "936 中文（PRC GB2312）"
    GBK = "936 中文（PRC GBK）"
    UNICODE = "UNICODE"

    @staticmethod
    def values():
        return tuple(f.value for f in Charset)

    @staticmethod
    def names():
        return tuple(f.name.lower() for f in Charset)

    @staticmethod
    def get_name(value):
        for k, v in Charset.__members__.items():
            if v.value == value:
                return k.lower()
        return None

    @staticmethod
    def get_charset_region(value):
        if value == Charset.GB2312.value:
            return '0xB0A1', '0xF7FF'
        elif value == Charset.GBK.value:
            return '0xB0A1', '0xFEFF'
        elif value == Charset.UNICODE.value:
            return '0x4E00', '0x9FFF'
